#include <bits/stdc++.h>
using namespace std;
const int N=1e6+5;
struct Tree{
    int l,r,ad,sum;
}tree[4*N];
int p[N],n,m,T,L,V,a[N],v[N],d[N],num[N];
struct qujian{
    int l,r,id[N],n_i;
}Q[2*N];
int num_Q=0;
bool iclu(int i,int j){
    if(Q[i].l<=p[j]&&Q[i].r>=p[j]){
        return true;
    }
    return false;
}
void ask_Q(int d,int v,int a,int L,int V){
    if(a>=0){
        if(v<V){
            if(d+(V*V-v*v)/(2*a)<=L)
            Q[++num_Q].r=d+(V*V-v*v)/(2*a);
            Q[num_Q].l=L;
            for(int j=1;j<=m;j++){
                if(iclu(num_Q,j)){
                    Q[num_Q].id[++Q[num_Q].n_i]=j;
                    num[j]+=1;
                }
            }
        }
        else {
            Q[++num_Q].r=d;
            Q[num_Q].l=L;
            for(int j=1;j<=m;j++){
                if(iclu(num_Q,j)){
                    Q[num_Q].id[++Q[num_Q].n_i]=j;
                    num[j]+=1;
                }
            }
            return;
        }
    }
    else if(a<0){
        if(v>V){
            if(d+(v*v-V*V)/(2*a)<=L){
                Q[++num_Q].l=d;
                Q[num_Q].r=d+(v*v-V*V)/(2*a);
                for(int j=1;j<=m;j++){
                if(iclu(num_Q,j)){
                    Q[num_Q].id[++Q[num_Q].n_i]=j;
                    num[j]+=1;
                }
            }
            }
            else {
                Q[++num_Q].l=d;
                Q[num_Q].r=d+(v*v-V*V)/(2*a);
                for(int j=1;j<=m;j++){
                if(iclu(num_Q,j)){
                    Q[num_Q].id[++Q[num_Q].n_i]=j;
                    num[j]+=1;
                }
            }
                return;
            }
        }
    }
    return;
}

int main(){
    scanf("%d",&T);
    scanf("%d %d %d %d",&n,&m,&L,&V);
    while(T--){
        for(int i=1;i<=n;i++){
            scanf("%d %d %d",&d[i],&v[i],&a[i]);
        }
        for(int i=1;i<=m;i++){
            scanf("%d",&p[i]);
        }
        for(int i=1;i<=n;i++){
            ask_Q(d[i],v[i],a[i],L,V);
        }
    }
}
